import { Body, Controller, Get, Post, Res, HttpStatus, UploadedFile, UseInterceptors, HttpException, Request } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { Response } from 'express';
import { ShieLD } from './shield.entity';
import { ShieLDService } from './shield.service';

import {join, resolve} from 'path'
import { createWriteStream } from 'fs';

import {
  apibefore
} from '../../router'
import { ValidRSAInterceptor } from 'src/interceptor/validRSA';
import { ValidTokenInterceptor } from 'src/interceptor/validToken';

@Controller(apibefore('/shieLd'))
export class ShieIDController {
  constructor(private readonly shieLdService: ShieLDService) {}


  @Post('/shieLd_Video')
  @UseInterceptors(ValidTokenInterceptor)
  @UseInterceptors(ValidRSAInterceptor)
  async shieLd_Video(@Body() shieIdParams: { video_id: number}, @Request() req) {
    let wx_user = req.headers.wx_user
    const shield = new ShieLD()
    shield.type = 1
    shield.video_id = shieIdParams.video_id
    shield.wx_user = wx_user
    shield.create_time = new Date()
    return await this.shieLdService.create(shield)
  }

  @Post('/update')
  update(@Body() shieIdParams: { id: number; title: string; desc: string, wx_user: string, gm_user: number,video_url: string }) {

  }

  @Get('/findAll')
  async findAll() {

  }

  @Post('/remove')
  async remove(@Body() shieIdParams: { id: number }){
    return await this.shieLdService.remove(shieIdParams.id)
  }

  deleteVideo(FileId: string, then: Function, catchF: Function){

  }
}
